package server;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class WordListHandeler {
	private String filename;

	public WordListHandeler(String filename) {
		this.filename = filename;
	}

	public String[] readFile() {
		try {
			FileReader fstream = new FileReader(filename);
			BufferedReader in = new BufferedReader(fstream);
			String s = null;
			ArrayList<String> wordList = new ArrayList<String>();

			while ((s = in.readLine()) != null) {
				wordList.add(s);
			}

			String[] r = new String[wordList.size()];
			for (int i = 0; i < r.length; i++) {
				r[i] = wordList.get(i);
			}
			in.close();
			return r;

		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
			return null;
		}

	}

}
